import logging

# 日志方法
def get_logger(name='test_logger'):
    logger = logging.getLogger(name)
    if logger.handlers:
        fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        # 文件日志
        file_hd = logging.FileHandler('rizhi.log', encoding='utf-8')
        file_hd.setFormatter(fmt)
        logger.addHandler(file_hd)
        # 控制台日志
        kong_hd = logging.StreamHandler()
        kong_hd.setFormatter(fmt)
        logger.addHandler(kong_hd)

        logger.setLevel(logging.INFO)
    return logger
